# -*- coding: utf-8 -*-
"""
 @Time    : 2021/2/20 下午4:42
 @Author  : tgy
 
"""
import struct
import json


def test01():
    ...
    num = 100
    res = struct.pack('i', num)
    print(res)
    print(struct.unpack('i', res))


def test02():
    ...
    size = 10
    file_name = 'pyrhon'
    pack_str = struct.pack(f'i{len(file_name)}s', size, file_name.encode('utf-8'))
    print(struct.unpack(f'i{len(file_name)}s', pack_str))


class File:
    ...

    def __init__(self, size, name):
        ...
        self.size = size
        self.name = name


def test03():
    ...
    f = File(size=201,name='追寻')
    print(json.dumps(f.__dict__).encode('utf-8'))


if __name__ == '__main__':
    ...
    test03()
